package org.ruanjj.designmodel.buildermodel;


//建造者模式
public class User {
   private int age;
   private String name;
   private String sex;

   public User(){}

   public User(int age, String name, String sex){
      this.age = age;
      this.name = name;
      this.sex = sex;
   }

   public String getName(){
      return name;
   }

   public static AnimalBuilder builder(){
      return new AnimalBuilder();
   }


   public static class AnimalBuilder{
      private int age;
      private String name;
      private String sex;
      public AnimalBuilder setAge(int age){
         this.age = age;
         return this;
      }
      public AnimalBuilder setName(String name){
         this.name = name;
         return this;
      }
      public AnimalBuilder setSex(String sex) {
         this.sex = sex;
         return this;
      }
       User build(){
            return new User(age,name,sex);
      }
   }
}
